<?php
try {
  $plugin = new stdClass();
  $plugin->folder = basename(dirname(__FILE__));
  DbUtils::add($myPdo, 'pz2_plugin', $plugin);
} catch (PDOException $e) {
}

$sql = "CREATE TABLE IF NOT EXISTS `" . TABLE_NAME_PREFIX_PLUGIN . "profile`(
         `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
         `account` varchar(64) DEFAULT '',
         `password` varchar(64) DEFAULT ''
        ) ENGINE=MYISAM;";
$myPdo->exec($sql);

//$pass = md5(123456);
//$sql = "INSERT INTO " . TABLE_NAME_PREFIX_PLUGIN . "user_profile values (NULL, 'admin', '$pass')";
//$myPdo->exec($sql);

$sql = "CREATE TABLE IF NOT EXISTS `" . TABLE_NAME_PREFIX_PLUGIN . "client`(
         `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
         `track_id` varchar(16) UNIQUE DEFAULT '',
         `account` varchar(64) UNIQUE DEFAULT '',
         `password` varchar(64) DEFAULT '',
         `reg_date` date DEFAULT '0000-00-00',
         `last_login` date DEFAULT '0000-00-00',
         `name` varchar(64) DEFAULT '',
         `phone` varchar(64) DEFAULT '',
         `is_actived` tinyint(1) DEFAULT 0,
         `ip` varchar(64) DEFAULT '',
         `ip_place` varchar(64) DEFAULT ''
        ) ENGINE=MYISAM;";
$myPdo->exec($sql);

$sql = "CREATE TABLE IF NOT EXISTS `" . TABLE_NAME_PREFIX_PLUGIN . "comp`(
         `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
         `track_id` varchar(16) UNIQUE DEFAULT '',
         `date` date DEFAULT '0000-00-00',
         `title` varchar(256) DEFAULT '',
         `description` text,
         `is_finished` tinyint(1) DEFAULT 0
        ) ENGINE=MYISAM;";
$myPdo->exec($sql);

$sql = "CREATE TABLE IF NOT EXISTS `" . TABLE_NAME_PREFIX_PLUGIN . "comp_prize`(
         `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
         `comp_track_id` varchar(16) DEFAULT '',
         `order_number` double DEFAULT 0,
         `title` varchar(256) DEFAULT '',
         `price` decimal(10, 2) DEFAULT 0.00,
         `size` float DEFAULT 0,
         `path` varchar(256) DEFAULT ''
        ) ENGINE=MYISAM;";
$myPdo->exec($sql);

$sql = "CREATE TABLE IF NOT EXISTS `" . TABLE_NAME_PREFIX_PLUGIN . "comp_pic`(
         `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
         `comp_track_id` varchar(16) DEFAULT '',
         `size` float DEFAULT 0,
         `path` varchar(256) DEFAULT ''
        ) ENGINE=MYISAM;";
$myPdo->exec($sql);

$sql = "CREATE TABLE IF NOT EXISTS `" . TABLE_NAME_PREFIX_PLUGIN . "comp_entry`(
         `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
         `track_id` varchar(16) UNIQUE DEFAULT '',
         `date` date DEFAULT '0000-00-00',
         `client_id` int DEFAULT 0,
         `comp_track_id` varchar(16) DEFAULT '',
         `address` text,
         `total_votes` int DEFAULT 0,
         `is_confirmed` tinyint(1) DEFAULT 0,
         `is_recommended` tinyint(1) DEFAULT 0,
         `is_read` tinyint(1) DEFAULT 0
        ) ENGINE=MYISAM;";
$myPdo->exec($sql);

$sql = "CREATE TABLE IF NOT EXISTS `" . TABLE_NAME_PREFIX_PLUGIN . "comp_entry_pic`(
         `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
         `comp_track_id` varchar(16) DEFAULT '',
         `comp_entry_track_id` int DEFAULT 0,
         `client_id` int DEFAULT 0,
         `description` varchar(256) DEFAULT '',
         `size` float DEFAULT 0,
         `path` varchar(256) DEFAULT ''
        ) ENGINE=MYISAM;";
$myPdo->exec($sql);

$sql = "CREATE TABLE IF NOT EXISTS `" . TABLE_NAME_PREFIX_PLUGIN . "comp_entry_vote`(
         `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
         `date` date DEFAULT '0000-00-00',
         `comp_entry_id` int DEFAULT 0,
         `comp_track_id` varchar(16) DEFAULT '',
         `comp_entry_client_id` int DEFAULT 0
        ) ENGINE=MYISAM;";
$myPdo->exec($sql);

$sql = "CREATE TABLE IF NOT EXISTS `" . TABLE_NAME_PREFIX_PLUGIN . "comp_entry_comment`(
         `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
         `datetime` date DEFAULT '0000-00-00 00:00:00',
         `comp_entry_id` int DEFAULT 0,
         `comp_track_id` varchar(16) DEFAULT '',
         `to_id` int DEFAULT 0,
         `from_id` int DEFAULT 0,
         `title` varchar(1024) DEFAULT '',
         `is_read` tinyint(1) DEFAULT 0
        ) ENGINE=MYISAM;";
$myPdo->exec($sql);
?>